public class GirlFriendTest {
    public static void main(String[] args) {

    }
}

//懒汉式
class GirlFriend{
    //1.类的构造器私有化
    private GirlFriend(){

    };

    //2.在类的内部创建当前类的实例
    private static GirlFriend  instance = null;  ///只声明当前对象,并不创建

    //3.提供私有属性的get方法,获取当前instance实例,如果未创建对象则在方法内部创建
    public GirlFriend getInstance(){
        if (instance == null){
            instance = new GirlFriend();
        }
            return instance;
    }
}